#include "gui/notificationmanager.h"

#include "gui/guimessage.h"
#include "gui/notification.h"

#include "gamestate.h"
#include "player.h"
#include "simulation.h"

NotificationManager::NotificationManager():Widget(){
//    Notification* notif1 = new Notification("NotifTest1", -1, 1);
//    Notification* notif2 = new Notification("NotifTest2", -1, 1);
//    Notification* notif3 = new Notification("NotifTest3", -1, 1);
//    PostNotification(notif1);
//    PostNotification(notif2);
//    PostNotification(notif3);
}

void NotificationManager::Draw(){
    for(unsigned int i=0;i<notifications.size();i++){
        notifications.at(i)->Sety(i*60+200);
        notifications.at(i)->Draw();
    }
}

void NotificationManager::EndTurn(){
    for(unsigned int i=0;i<notifications.size();i++){
        delete notifications.at(i);
    }
    notifications.clear();
}

void NotificationManager::PostNotification(Notification* notif){
    std::cout<<"Notification recieved\n";
    std::cout<<"Notification length: "<<notifications.size()<<std::endl;
//    Player* activePlayer = gamestate->GetPlayer(simulation->ActivePlayer());
//    if(activePlayer->IsAI()==false){
        notifications.push_back(notif);
//    }
//    else{
//        // Ignore because the AI can't see this shit anyway
//    }
    std::cout<<"Notification length: "<<notifications.size()<<std::endl;
}

void NotificationManager::RemoveNotification(int id){
    for(unsigned int i=0;i<notifications.size();i++){
        if(notifications.at(i)->GetID()==id){
            delete notifications.at(i);
            notifications.erase(notifications.begin()+i);
            return;
        }
    }
}
